#include <cstdio>
#include <string>
#include <vector>

using namespace std;

class Base {
public:
	virtual void print() = 0;
	void operator =(const Base& base) {
		this->number = 0;
		this->str = ",,,";
	}
	int number;
	std::string str;
};

class A: public Base {
public:
	A(const int& number) { this->number = number; }
	virtual void print() {
		printf("A: %d\n", number);
	}
};

class B: public Base {
public:
	B(const std::string& str) { this->str = str; }
	virtual void print() {
		printf("B: %s\n", str.c_str());
	}
};

class List {
public:
	void operator + (const std::string& str) {
		list.push_back(std::make_shared<B>(str));
	}
	void operator + (const int& number) {
		list.push_back(std::make_shared<A>(number));
	}

	Base& operator [] (int index) {
		return *list[index];
	}

	std::vector<std::shared_ptr<Base>> list;
};


int main(int argc, const char ** argv) {
	List list;
	list + 123;
	list + "123";
	list[0] = A(5555);
	list[0].print();
	return 0;
}